
;!include "MUI2.nsh"
;!define MUI_ICON ".\images\favicon.ico" ;Value

  
Name "routeviewer"

Icon ".\images\favicon.ico"

;SetCompress off
SetCompressor /SOLID lzma

OutFile "routeviewer.exe"

InstallDir $PROGRAMFILES\routeviewer

; Registry key to check for directory (so if you install again, it will 
; overwrite the old one automatically)
InstallDirRegKey HKLM "Software\routeviewer" "Install_Dir"

; Request application privileges for Windows Vista
RequestExecutionLevel admin

;--------------------------------

; Pages

  ;!insertmacro MUI_PAGE_WELCOME
  ;!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt"
  ;!insertmacro MUI_PAGE_COMPONENTS
  ;!insertmacro MUI_PAGE_DIRECTORY
  ;!insertmacro MUI_PAGE_INSTFILES
  
  ;!insertmacro MUI_UNPAGE_CONFIRM
  ;!insertmacro MUI_UNPAGE_INSTFILES
  
Page components
Page directory
Page instfiles

UninstPage uninstConfirm
UninstPage instfiles

;--------------------------------
;Languages
 
  ;!insertmacro MUI_LANGUAGE "English"
;--------------------------------

; The stuff to install
Section "routeviewer (required)"

  SectionIn RO
  
  ; Set output path to the installation directory.
  SetOutPath $INSTDIR
  
  ; Put file there
    File ".\release\routeviewer.exe"
    File ".\release\libgcc_s_dw2-1.dll"
    File ".\release\libstdc++-6.dll"
    File ".\release\libusb0.dll"
    File ".\release\mingwm10.dll"
    File ".\release\QtCore4.dll"
    File ".\release\QtGui4.dll"
    File ".\release\QtNetwork4.dll"
    File ".\release\QtXml4.dll"
    File ".\release\SiUSBXp.dll" 
  
  ; File ".\release\routeviewer.exe" x
  ; File ".\release\libgcc_s_dw2-1.dll" x
  ; File ".\release\libusb0.dll" x
  ; File ".\release\mingwm10.dll" x
  ; File ".\release\QtCore4.dll" x
  ; File ".\release\QtGui4.dll" x
  ; File ".\release\QtNetwork4.dll" x
  ; File ".\release\QtXml4.dll" x
  ; File ".\release\SiUSBXp.dll" x 
  
  
  SetOutPath $INSTDIR\images
  File ".\images\favicon.ico"
  File ".\images\routeviewer.bmp"
  File ".\images\routeviewer.svg"
  File ".\images\routeviewerpng.png"
  
  
  ; Write the installation path into the registry
  WriteRegStr HKLM SOFTWARE\routeviewer "Install_Dir" "$INSTDIR"
  
  ; Write the uninstall keys for Windows
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\routeviewer" "DisplayName" "routeviewer"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\routeviewer" "UninstallString" '"$INSTDIR\uninstall.exe"'
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\routeviewer" "NoModify" 1
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\routeviewer" "NoRepair" 1
  WriteUninstaller "uninstall.exe"
  
SectionEnd

; Optional section (can be disabled by the user)
Section "Start Menu Shortcuts"

  CreateDirectory "$SMPROGRAMS\routeviewer"
  CreateShortCut "$SMPROGRAMS\routeviewer\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
  CreateShortCut "$SMPROGRAMS\routeviewer\routeviewer.lnk" "$INSTDIR\routeviewer.exe" "" "$INSTDIR\routeviewer.exe" 0
  
SectionEnd

;--------------------------------

; Uninstaller

Section "Uninstall"
  
  ; Remove registry keys
  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\routeviewer"
  DeleteRegKey HKLM SOFTWARE\routeviewer

  ; Remove files and uninstaller
  Delete $INSTDIR\routeviewer.exe

  ; we continue to delete qwt5.dll becvause people don't always uninstall before they install
  ;; so a subsequent uninstall still should remove it if it is there
  
    Delete $INSTDIR\libgcc_s_dw2-1.dll
    Delete $INSTDIR\libstdc++-6.dll
    Delete $INSTDIR\libusb0.dll
    Delete $INSTDIR\mingwm10.dll
    Delete $INSTDIR\QtCore4.dll
    Delete $INSTDIR\QtGui4.dll
    Delete $INSTDIR\QtNetwork4.dll
    Delete $INSTDIR\QtXml4.dll
    Delete $INSTDIR\SiUSBXp.dll  
    Delete $INSTDIR\uninstall.exe
  
  ; Delete $INSTDIR\libgcc_s_dw2-1.dll 
  ; Delete $INSTDIR\libusb0.dll 
  ; Delete $INSTDIR\mingwm10.dll 
  ; Delete $INSTDIR\QtCore4.dll 
  ; Delete $INSTDIR\QtGui4.dll 
  ; Delete $INSTDIR\QtNetwork4.dll 
  ; Delete $INSTDIR\QtXml4.dll 
  ; Delete $INSTDIR\SiUSBXp.dll 
  ; Delete $INSTDIR\uninstall.exe 
  
  Delete $INSTDIR\images\favicon.ico
  Delete $INSTDIR\images\routeviewer.bmp
  Delete $INSTDIR\images\routeviewer.svg
  Delete $INSTDIR\images\routeviewerpng.png

  Delete $INSTDIR\images\

  Delete $INSTDIR\
  

  ; Remove shortcuts, if any
  Delete "$SMPROGRAMS\routeviewer\*.*"

  ; Remove directories used
  RMDir "$SMPROGRAMS\routeviewer"
  RMDir "$INSTDIR"

SectionEnd